﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Reflection;
using Microsoft.Phone.Tasks;

namespace TheVerge.Phone.Pages
{
    public partial class AboutPage : PhoneApplicationPage
    {
        public AboutPage()
        {
            InitializeComponent();

            var assembly = Assembly.GetExecutingAssembly();

            //-- Version Information
            var nameHelper = new AssemblyName(assembly.FullName);
            version.Text = nameHelper.Version.ToString();

            //-- Description
            var description = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false).OfType<AssemblyDescriptionAttribute>().FirstOrDefault();
            tbDescription.Text = description.Description;
        }
        

#if WP_8
        private async void MoreFrom_Click(object sender, RoutedEventArgs e)
        {
            await Windows.System.Launcher.LaunchUriAsync(new Uri(@"zune:search?publisher=MasterDevs"));
#else
         private void MoreFrom_Click(object sender, RoutedEventArgs e)
        {   var mp = new MarketplaceSearchTask();
            mp.ContentType = MarketplaceContentType.Applications;
            mp.SearchTerms = @"MasterDevs";
            mp.Show();
#endif
        }

        private void Rate_Click(object sender, RoutedEventArgs e)
        {
            var mp = new MarketplaceReviewTask();
            mp.Show();
        }
    }
}